<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue路由开发-路由嵌套</title>
</head>
<style>
    body {
        font-family: Arial, sans-serif;
        background-color: #f5f5f5;
        /* 背景色 */
    }

    h1,
    h2 {
        color: #333;
        /* 标题文字颜色 */
    }

    .container {
        max-width: 960px;
        margin: auto;
        padding: 20px;
        background-color: white;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    }

    ul {
        list-style-type: none;
        padding-left: 0;
    }

    li {
        display: inline-block;
        margin-right: 10px;
    }

    a {
        text-decoration: none;
        color: #007BFF;
    }

    a:hover {
        color: #0056b3;
    }

    .router-link-active {
        color: #42b983;
        font-weight: bold;
    }

    .container router-link {
        margin: 0 10px;
        padding: 5px 10px;
        border-radius: 4px;
    }

    .container router-link:hover {
        background-color: #f0f0f0;
    }
</style>

<body>
    <div id="app" class="container">
        <router-view></router-view>
    </div>
    <!-- 一级 -->
    <template id="dsh">
        <div>
            <h1>董事会</h1>
            <router-link to="/dsh/sc">市场经理</router-link>
            <router-link to="/dsh/rs">人事经理</router-link>
            <router-link to="/dsh/cp">产品经理</router-link>
            <router-view></router-view>
        </div>
    </template>

    <!-- 二级-->
    <template id="sc">
        <div>
            <h2>市场经理</h2>
            <router-link to="/dsh/sc/scb">市场部</router-link>
            <router-link to="/dsh/sc/sj/">设计部</router-link>
            <router-link to="/dsh/sc/ywb">业务部</router-link>
            <router-link to="/dsh/rs/kfb">客服部</router-link>
            <router-view></router-view>
        </div>
    </template>
    <template id="rs">
        <div>
            <h2>人事经理</h2>
            <router-link to="/dsh/rs/cwb">财务部</router-link>
            <router-link to="/dsh/rs/xzb">行政部</router-link>
            <router-link to="/dsh/rs/rlzyb">人力资源部</router-link>
            <router-view></router-view>
        </div>
    </template>
    <template id="cp">
        <div>
            <h2>产品经理</h2>
            <router-link to="/dsh/cp/wlb">网络部</router-link>
            <router-link to="/dsh/cp/kfb">开发部</router-link>
            <router-link to="/dsh/cp/jsb">技术部</router-link>
            <router-view></router-view>
        </div>
    </template>
    <!-- 三级-->
    <template id="sheji">
        <div>
            <ul>
                <li>设计一部</li>
                <li>设计二部</li>
            </ul>
        </div>
    </template>
    <template id="kefu">
        <div>
            <ul>
                <li>客服服务</li>
                <li>技术支持</li>
            </ul>
        </div>
    </template>
    <template id="kaifa">
        <div>
            <ul>
                <li>开发一部</li>
                <li>开发二部</li>
            </ul>
        </div>
    </template>


</body>

</html>
<script type="module">
    import { } from '../js/vue.js';
    import { } from '../js/vue-router3.js';

    let dsh = { template: "#dsh" }
    let sc = { template: "#sc" }
    let rs = { template: "#rs" }
    let cp = { template: "#cp" }
    let sheji = { template: "#sheji" };
    let kefu = { template: "#kefu" };
    let kaifa = { template: "#kaifa" };
    //路由定义
    let routes = [
        { path: '/', redirect: '/dsh' },
        {
            path: '/dsh',
            component: dsh,
            children: [
                {
                    path: 'sc',
                    component: sc,
                    children: [
                        { path: 'scb', component: sheji }, // 添加市场部路由
                        { path: 'sj', component: sheji },
                        { path: 'ywb', component: kefu },  // 添加业务部路由
                        { path: 'kfb', component: kefu }
                    ]
                },
                {
                    path: 'rs',
                    component: rs,
                    children: [
                        { path: 'cwb', component: kefu },    // 添加财务部路由
                        { path: 'xzb', component: kefu },    // 添加行政部路由
                        { path: 'rlzyb', component: kefu },  // 添加人力资源部路由
                        { path: 'kfb', component: kefu }
                    ]
                },
                {
                    path: 'cp',
                    component: cp,
                    children: [
                        { path: 'wlb', component: kaifa },   // 添加网络部路由
                        { path: 'kfb', component: kaifa },
                        { path: 'jsb', component: kaifa }    // 添加技术部路由
                    ]
                }
            ]
        }
    ];

    //路由对象
    const router = new VueRouter({
        routes
    })


    new Vue({
        el: '#app',
        data: {
            msg: 'hello world'
        },
        methods: {
            //自定义方法
        },
        computed: {
            //计算属性
        },
        router,
    })
</script>